package graduate.wangyaqi.UploadFile;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.Optional;

@Service
public class UploadFileService {
    @Resource
    private UploadFileRepository uploadFileRepository;

    //保存数据
    @Transactional
    public void save(UploadFile file) {
        uploadFileRepository.save(file);
    }

    //删除数据
    @Transactional
    public void delete(long id) {
        uploadFileRepository.deleteById(id);
    }

    //查询数据
    @Transactional
    public Iterable<UploadFile> getAll() {
        Iterable<UploadFile> file = uploadFileRepository.findAll();
        return file;
    }

    @Transactional
    public Optional<UploadFile> findById(Long aLong){
        return uploadFileRepository.findById(aLong);
    };
}
